import { IQueue } from "./base";
import { Heap } from "./Heap";

export class PriorityQueue<T> implements IQueue<T> {

    private heap: Heap<T>;
    constructor(data: T[], compareTo: (a: T, b: T) => number) {
        this.heap = new Heap<T>(data, compareTo);
    }

    enqueue(v: T) {
        this.heap.insert(v);
    }

    dequeue(): T{
        return this.heap.delete();
    }

    size() {
        return this.heap.size();
    }

}